# arr=list(map(int,input().split()))
arr = [0,0,2,3,5,9]
res=[]
tem_1=[2,1,0]
tem_2=[4,3,2,1,0]
tem_3=[5,4,3,2,1,0]
tem_4=[9,8,7,6,5,4,3,2,1,0]
def getEle(arr,res,tem):
    for i in tem:
        if i not in arr:
            continue
        arr.remove(i)
        res.append(i)
        break
def getResult():
    getEle(arr,res,tem_1)
    if len(res)!=1:
        return "invalid"
    getEle(arr,res,tem_2)
    if len(res)!=2:
        return "invalid"
    getEle(arr,res,tem_3)
    if len(res)!=3:
        return "invalid"
    getEle(arr,res,tem_4)
    if len(res)!=4:
        return "invalid"
    getEle(arr,res,tem_3)
    if len(res)!=5:
        return "invalid"
    getEle(arr,res,tem_4)
    if len(res)!=6:
        return "invalid"
    print(res)
print(getResult())